/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Game;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.util.ArrayList;

/**
 *
 * @author Kevin Tracy
 */
public class InputManager implements KeyListener{


    TurnManager turnManager;

    public InputManager()
    {
        turnManager = turnManager.getTurnManager();
    }

    public void keyPressed(KeyEvent e) {
        int keyCode = e.getKeyCode();
        String keyText = e.getKeyText(keyCode).toLowerCase();

        Player currentPlayer = turnManager.getCurrentPlayer();
                
        int xPos = currentPlayer.getCurrentX();
        int yPos = currentPlayer.getCurrentY();
        int offset = 30;

        if(keyText.equals("up"))
        {
            currentPlayer.setDestYPos(yPos + offset);
        }
        else if(keyText.equals("down"))
        {
            currentPlayer.setDestYPos(yPos - offset);
        }

        else if(keyText.equals("right"))
        {
            currentPlayer.setDestXPos(xPos + offset);
        }
        else if(keyText.equals("left"))
        {
            currentPlayer.setDestXPos(xPos - offset);
        }
        turnManager.makeMove();
        
    }

    public void keyReleased(KeyEvent e) {

    }

    public void keyTyped(KeyEvent e) {

    }

}